<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="hexinyang">		
		<title>处理失效卡</title>
		<script language="javascript" type="text/javascript" src="../script/print.js"></script>
		<script language="javascript" type="text/javascript" src="../script/pivot.js"></script>
		<script language="javascript" src="../script/common.js" type="text/javascript"></script>
		<script language="javascript" src="../script/card.js" type="text/javascript"></script>
		<script language="javascript" type="text/javascript">
	var cardPin;
	function load(){
		Eui.showNavigation();
		setPages(["readcardview","detview"]);
		
		Rpc.loadPage("formDetail","card_detail_div.html");	
	}
	function onReadCard(){
		var c;
		try{
			c = CardMgnt.getCardAndPin();
			cardPin = c.cardPin;
		}catch(e){showError(e.description);return;}
		
		DWR.call("mgntQueryService.checkExtendExpired",c.asn,function(data){
			var cardObj = CardMgnt.convertCardObject(data);
			Common.setValues(detailForm,cardObj);
			expiredForm.days.value = data.days;
			expiredForm.newExpiredTime.value = data.expiredTime.format();
			expiredForm.feeAmount.value = Format.fenToYuan(CardMgnt.getFee(Constants.ACCOUNT_FEE_EXPIRED_CARD,data.cardType.id));
			$("readCardBtn").disabled = true;
			$("saveExpiredBtn").disabled = false;
		});
	}
	function onCancel(){
		switchPage("readcardview");
		cardPin = null;
		detailForm.reset();
		expiredForm.reset();
		$("readCardBtn").disabled = false;
		$("saveExpiredBtn").disabled = true;
	}
	//确认激活
	function saveExpired(){
		var asn = detailForm.asn.value;
		if (!CardMgnt.checkCardAsn(asn)) return;
		var newExpiredTime = expiredForm.newExpiredTime.value;
		
		if (showQuestion("是否延长有效期至"+newExpiredTime+"？")){		
			DWR.call("cardMgntService.editExpiredDate",asn,newExpiredTime,function(v){
				CardMgnt.editExpiredDate(asn,newExpiredTime.replace(/-/g , ""),cardPin);
				
				showInformation("有效期延长到" + newExpiredTime);//提示信息
				
				switchPage("detview");
				CardMgnt.showPrintView("detview","abate_bill",v.logId,"延长有效期凭证");
				try{
					WebPrint.print("billview");
				}catch(e){showError("打印出错："+e.description);return;}
				
			},{blockScreen:true});
		}
	}
	

		</script>
	</head>
<body onload="load()" onunload="releaseCard()">
	<!--页面导航-->
	<div class="nav"><div id="nav">&nbsp;</div></div>
		
	<div id="readcardview">
		<form id="detailForm" name="detailForm">
			<div class="form">
				<div class="formTitle">卡片明细信息</div>
				<div id="formDetail"></div>
			</div>
		</form>
		<div id="bindinfodiv">
			<div class="form">
				<form id="expiredForm" name="expiredForm">
					<div class="formTitle">延长有效期</div>
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="label5">
						<tr>
							<td><label>延长有效期</label> <input type="text" name="days" readonly class="readonly"> 天</td>
							<td><label>新有效期</label> <input type="text" name="newExpiredTime" readonly class="readonly"></td>
						</tr>
						<tr>
							<td><label>手 续 费</label> <input type="text" name="feeAmount" readonly class="readonly"></td>
							<td>&nbsp;</td>
						</tr>
					</table>
				</form>
			</div>
		</div>
		<p>
			<button id="readCardBtn" onclick="onReadCard()">读 卡</button>
			<button id="saveExpiredBtn" onclick="saveExpired()" disabled>延长有效期</button>
			<button onclick="onCancel()">重 置</button>
		</p>
	</div>

	<div id="detview" style="display:none;">
	</div>
</body>
</html>